﻿function changeBackground(obj, newBg) {
    obj.style.background = newBg;
}

function selectDeckToDetail(iddeck) {
    sendData('Handlers/DecksHandler.ashx', 'action=deckdetail&iddeck=' + iddeck, '', setDeckCardsDetail);
}

function setDeckCardsDetail(data) {
    $divDeckDet = $('#divDeckDet');
    var detail = eval(data);
    var divCardDetail;
    var divQuantity;
    var divImage;
    var imgCard;
    var divName;
    var divCleared;
    $divDeckDet.empty();
    for (i = 0; i < detail.length; i++) {
        divCleared = document.createElement('div');
        divCleared.className = 'cleared';
        divCardDetail = document.createElement('div');
        divCardDetail.className = 'floatLeft';
        divImage = document.createElement('div');
        divImage.className = 'floatLeft cardDetail';
        imgCard = document.createElement('img');
        imgCard.className = 'imgCardTiny';
        imgCard.src = 'Images/Cards/' + detail[i].CodeCard + '.jpg';
        divImage.appendChild(imgCard);
        divCardDetail.appendChild(divImage);
        divQuantity = document.createElement('div');
        divQuantity.className = 'floatLeft cardDetail';
        divQuantity.innerHTML = 'x' + detail[i].Quantity;
        divCardDetail.appendChild(divQuantity);
        divName = document.createElement('div');
        divName.className = 'floatLeft cardDetail';
        divName.innerHTML = detail[i].Name;
        divCardDetail.appendChild(divName);
        $divDeckDet.append(divCardDetail).append(divCleared);
    }
    $('#scrollDeckDet').tinyscrollbar_update();
}

$(function () {
    $('#scrollDeckDet').tinyscrollbar();
    $('#divTabDecks').tabs(); 
});